﻿/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: FZH
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;
using FriendStar.Code;
using FriendStar.Domain.Entity.BOM;
using FriendStar.Domain.IRepository.BOM;
using FriendStar.Repository.BOM;

namespace FriendStar.Application.BOM
{
    /// <summary>
	/// 数据视图 V_ZSJ_11_LJ_Production 对应的数据应用功能类。
	/// </summary>
	public class V_ZSJ_11_LJ_ProductionApp
    {       
        private string UseUnit = Configs.GetValue("UseUnit");  

        private IV_ZSJ_11_LJ_ProductionRepository service = new V_ZSJ_11_LJ_ProductionRepository();

        public List<V_ZSJ_11_LJ_ProductionEntity> GetList(Pagination pagination, string keyword)
        {
            var expression = ExtLinq.True<V_ZSJ_11_LJ_ProductionEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            if (!string.IsNullOrEmpty(keyword))
            {
                expression = expression.And(t => t.FProductionNO.Contains(keyword));
            }
            return service.FindList(expression, pagination);
        }

        public List<V_ZSJ_11_LJ_ProductionEntity> GetList(Pagination pagination, string CNFProductionNO, string CNFProductionName, string CNReferenceName)
        {
            var expression = ExtLinq.True<V_ZSJ_11_LJ_ProductionEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            if (!string.IsNullOrEmpty(CNFProductionNO))
            {
                expression = expression.And(t => t.FProductionNO.Contains(CNFProductionNO));
            }
            if (!string.IsNullOrEmpty(CNFProductionName))
            {
                expression = expression.And(t => t.FProductionName.Contains(CNFProductionName));
            }
            if (!string.IsNullOrEmpty(CNReferenceName))
            {
                expression = expression.And(t => t.ReferenceName.Contains(CNReferenceName));
            }
            return service.FindList(expression, pagination);
        }

        public V_ZSJ_11_LJ_ProductionEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }
    }
}